package com.whjz.dcfs.gis.struts.action;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.whjz.dcfs.ggts.dao.IDcfsGgtsJbxxDAO;
import com.whjz.dcfs.ggts.model.DcfsGgtsJbxx;
import com.whjz.dcfs.jzxx.dao.IDcfsJzSbJbxxDAO;
import com.whjz.dcfs.jzxx.model.DcfsJzSbJbxx;
import com.whjz.dcfs.util.BaseAction;

public class GisGgtsAction extends BaseAction{

	private static final long serialVersionUID = 1L;
	
	@Autowired
	private IDcfsGgtsJbxxDAO dcfsGgtsJbxxDAO;
	@Autowired
	public IDcfsJzSbJbxxDAO dcfsJzSbJbxxDAO;
	
	private DcfsJzSbJbxx dcfsJzSbJbxx;
	
	private DcfsGgtsJbxx dcfsGgtsJbxx;
	
	public void getDcfsGgtsJbxx_map() throws Exception{
		try{
			getHttpServletResponse().setCharacterEncoding("utf-8");
			List<DcfsGgtsJbxx> list=dcfsGgtsJbxxDAO.getDcfsGgtsJbxx_map(dcfsGgtsJbxx);
			StringBuffer sb=new StringBuffer();
			sb.append("{root:[");
			if(list!=null&&list.size()>0){
				for(int i=0;i<list.size();i++){
					sb.append("{");
					sb.append("TS_BH:'"+list.get(i).getTsbh()+"',");
					sb.append("TS_SJ:'"+list.get(i).getTssj()+"',");
					sb.append("TS_R:'"+list.get(i).getTsr()+"',");
					sb.append("TS_DD:'"+list.get(i).getTsdd()+"',");
					sb.append("TS_R_LXDH:'"+list.get(i).getTsrlxdh()+"',");
					sb.append("TS_SB_SSQY:'"+list.get(i).getTssbssqy()+"',");
					sb.append("TS_SB_LX:'"+list.get(i).getTssblx()+"',");
					sb.append("TS_SB_MC:'"+list.get(i).getTssbmc()+"',");
					sb.append("TS_SB_BH:'"+list.get(i).getTssbbh()+"',");
					sb.append("TS_QKMS:'"+list.get(i).getTsqkms()+"',");
					sb.append("TS_BZ:'"+list.get(i).getTsbz()+"',");
					sb.append("TS_ZT:'"+list.get(i).getTszt()+"'");
					sb.append("}");
					if(i < list.size()-1){
						sb.append(",");
					}
				}
			}
		     sb.append("]}");
		     getHttpServletResponse().getWriter().print(sb);
		}catch(Exception e){
			e.printStackTrace();
		}
	}
	
	public void insertDcfsGgtsJbxx() throws Exception{
		try{
			List<DcfsJzSbJbxx> list=dcfsJzSbJbxxDAO.getDcfsJzSbJbxxList_ggts(dcfsJzSbJbxx);
			String time_str = "";
			String time_str1= "";
			Date date = new Date();
			SimpleDateFormat stime = new SimpleDateFormat("yyyyMMddHHmmss");
			SimpleDateFormat stime1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			time_str = stime.format(date);
			time_str1=stime1.format(date);
			dcfsGgtsJbxx.setTsbh(time_str);
			dcfsGgtsJbxx.setTssj(time_str1);
			dcfsGgtsJbxx.setTssbbh(list.get(0).getJzsbbh());
			dcfsGgtsJbxx.setTssbmc(list.get(0).getJzsbmc());
			dcfsGgtsJbxx.setTssbssqy(list.get(0).getJzsbqy());
			dcfsGgtsJbxx.setTszt("未处理");
			dcfsGgtsJbxx.setTssblx("基站设备");
			dcfsGgtsJbxxDAO.insertDcfsGgtsJbxx(dcfsGgtsJbxx);
			getHttpServletResponse().getWriter().println("{success:'true',msg:'添加成功'}");
		}catch(Exception e){
			e.printStackTrace();
		}
	}

	public DcfsJzSbJbxx getDcfsJzSbJbxx() {
		return dcfsJzSbJbxx;
	}

	public void setDcfsJzSbJbxx(DcfsJzSbJbxx dcfsJzSbJbxx) {
		this.dcfsJzSbJbxx = dcfsJzSbJbxx;
	}

	public DcfsGgtsJbxx getDcfsGgtsJbxx() {
		return dcfsGgtsJbxx;
	}

	public void setDcfsGgtsJbxx(DcfsGgtsJbxx dcfsGgtsJbxx) {
		this.dcfsGgtsJbxx = dcfsGgtsJbxx;
	}

	
	
}
